package com.yanqu.road.entity.systemgroup.common;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;
import org.apache.mina.util.ConcurrentHashSet;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@FieldTypeAnnotation(tableName = "t_c_new_system_server_week_group", desc = "系统-后台跨服大分组，来自系统轮询的配置")
public class SystemServerGroupWeekData extends DataObject {

    @FieldTypeAnnotation(desc = "每周", update = true, select = true)
    private int weekId;

    @FieldTypeAnnotation(desc = "系统", update = true)
    private int systemId;

    @FieldTypeAnnotation(desc = "分组Id", update = true)
    private int groupId;

    @FieldTypeAnnotation(desc = "分组开服天数区间（配置最小值）")
    private int openDay;

    @FieldTypeAnnotation(desc = "区服范围")
    private List<Long> serverIdList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "指定跨服id")
    private int crossId;

    @FieldTypeAnnotation(desc = "时间")
    private Date addTime;

    //缓存
    private int num;

    // 商会跨服才有
    private boolean syncCrossServer = false;                                        // 是否同步到活动跨服
    private ConcurrentHashSet<Long> noSyncServerSet = new ConcurrentHashSet<>();    // 未同步的区服

    private int time;

    // ------------------------------------------------------

    public void setCrossServerIdNeedSync(int crossServerId) {
        this.crossId = crossServerId;
        this.syncCrossServer = false;
    }

    public void setServerSetNeedSync(List<Long> serverIdList) {
        this.serverIdList = serverIdList;
        this.noSyncServerSet = new ConcurrentHashSet<>(serverIdList);
    }

    // ------------------------------------------------------

    public int getWeekId() {
        return weekId;
    }

    public void setWeekId(int weekId) {
        if(this.weekId != weekId) {
            this.weekId = weekId;
            setUpdateOption();
        }
    }

    public int getSystemId() {
        return systemId;
    }

    public void setSystemId(int systemId) {
        if(this.systemId != systemId) {
            this.systemId = systemId;
            setUpdateOption();
        }
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        if(this.groupId != groupId) {
            this.groupId = groupId;
            setUpdateOption();
        }
    }

    public int getOpenDay() {
        return openDay;
    }

    public void setOpenDay(int openDay) {
        if(this.openDay != openDay) {
            this.openDay = openDay;
            setUpdateOption();
        }
    }

    public List<Long> getServerIdList() {
        return serverIdList;
    }

    public void setServerIdList(List<Long> serverIdList) {
        this.serverIdList = serverIdList;
        setUpdateOption();
    }

    public int getCrossId() {
        return crossId;
    }

    public void setCrossId(int crossId) {
        if(this.crossId != crossId) {
            this.crossId = crossId;
            setUpdateOption();
        }
    }

    public Date getAddTime() {
        return addTime;
    }

    public void setAddTime(Date addTime) {
        if(this.addTime != addTime) {
            this.addTime = addTime;
            setUpdateOption();
        }
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public boolean isSyncCrossServer() {
        return syncCrossServer;
    }

    public void setSyncCrossServer(boolean syncCrossServer) {
        this.syncCrossServer = syncCrossServer;
    }

    public ConcurrentHashSet<Long> getNoSyncServerSet() {
        return noSyncServerSet;
    }

    public void setNoSyncServerSet(List<Long> list) {
        this.noSyncServerSet = new ConcurrentHashSet<>(list);
    }

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        this.time = time;
    }
}
